---
title: Process your build
---

<ul class="main-content--version">
  <li>Current version:</li>
  <li><a class="active" href="/tutorials/getting-started/mac/process-build">Mac</a></li>
  <li><a href="/tutorials/getting-started/linux/process-build">Linux</a></li>
  <li><a href="/tutorials/getting-started/windows/process-build">Windows</a></li>
</ul>
<hr />

# Run your service
<%= partial "/shared/process_build_common" %>

Because the host operating system is OS X in this version of the tutorial, you must run your package inside a Docker container.

## Run in a Docker container
To show the portability of Habitat, export and run a Habitat service from within a Docker container through the following steps:

1. If you are not in the studio environment, change over to your plan directory and enter the studio.

        cd ~/habitat-example-plans/mytutorialapp
        hab studio enter

    > Note: When you created an origin key pair in `hab setup`, you were also asked if you wanted to setup a default origin. If you said yes, then the `HAB_ORIGIN` environment variable is overridden for you with the default origin name you created. This action will also import the secret origin key that matches the overridden origin name when you call `hab studio enter`.

2. Rebuild your package to include the changes made in the previous two steps.

        [1][default:/src:0]# build

3. Run `hab pkg export docker <youroriginname>/mytutorialapp` with the origin you chose at setup.

        [2][default:/src:0]# hab pkg export docker myorigin/mytutorialapp

    Habitat will proceed to unpack and install all necessary Habitat packages, including a Habitat supervisor, the mytutorialapp package, and all of its runtime dependencies. Then it will create an image using the Docker scratch image as the base and build up the rest of the image from there.

4. Once that process has completed, exit out of the studio, make sure Docker for Mac is running and run your Docker image inside a container on your host machine.

    > Note: We have to publish the Docker container port number to allow that container to be accessed by the host machine.

       $ docker run -it -p 8080:8080 myorigin/mytutorialapp

    You should see the supervisor start your Node.js application.

    <%= partial "/shared/process_build_run_output" %>

5. Because we are running this service in a Docker container on our host machine using Docker for Mac, you can simply connect to the Node.js app through your <a href="http://localhost:8080" target="_blank">localhost</a>.

    Here's an example of what you should see in your browser:

    ![Screen shot of node.js tutorial output](/images/nodejs-tutorial-output.png)

6. You can also re-run your Docker container and update the message value when your Habitat service starts up. To do this, you must pass in a Docker environment variable with the following format: `HAB_PACKAGENAME='keyname1=newvalue1 keyname2=newvalue2'`. For multiline environment variables, such as those in a TOML table, it's preferrable to place your changes in a .toml file and pass it in using `HAB_PACKAGENAME="$(cat foo.toml)"`.

    > Note: The package name in the environment variable must be uppercase, any dashes must be replaced with underscores, and if you are overriding values in a TOML table, you must override all values in the table.

    Here is how you change the message for mytutorialapp:

       $ docker run -e HAB_MYTUTORIALAPP='message="Habitat rocks!"' -p 8080:8080 -it myorigin/mytutorialapp

    Now refresh, or connect again to the local URL through your web browser.

    ![Screen shot of node.js output with new message](/images/nodejs-tutorial-update-output.png)

Congratulations, you have successfully built a package from scratch, run it locally, and tested out some of the configuration capabilities!

<hr>
<ul class="main-content--button-nav">
  <li><a href="/tutorials/getting-started/next-steps" class="button cta">Next Steps</a></li>
  <li><a href="/tutorials/getting-started/mac/configure-plan/">Back to previous step</a></li>
</ul>
